<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%@include file="common/tag.jsp"%>
<c:set var="CTX" value="${pageContext.request.contextPath}" />
<%@include file="common/indexhead.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
    
    <title>仓库新增页</title>
    </head>
  <style>
  .panel .panel-heading button {
  	padding: ;
	margin-left: ;
	background-color: ;
	border: ;
	outline: ;
  }
  </style>
 <body>
<div class="panel panel-primary">
	<div class="panel-heading">
		<div>
			<h3 class="panel-title">仓库新增页</h3>
		</div>
		<div class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<a class="btn btn-info" href="#" onclick="javascript:window.close();"><i class="fa fa-sign-out"></i>退出</a>
		</div>
		<div class="button"
			style="float: right;margin-top: -27px;margin-right: 5px;">
			<div class="btn btn-info"   onclick="tijiao()" href=""><i class="fa fa-check"></i>保存</div>
		</div>
	</div>
	<div class="panel-body" style="height:87%">

		<!-- <form modelAttribute="User"    id="userdetail" action="/user/update" method="POST" class="form-horizontal" -->
			<form   id="userdetail"  class="form-horizontal"
			style="width:90%;margin-top: 50px;">
			<fieldset>
				<div class="form-group">
					<label class="col-sm-2 control-label">仓库编码</label>
					<div class="col-sm-4">
						<input readOnly=true class="form-control" id="warehouseNumber" name="warehouseNumber" type="text"
						placeholder = "${number}" value = "${number}"/>
					</div>
					<label class="col-sm-2 control-label">仓库名称</label>
					<div class="col-sm-4">
						<input class="form-control" id="warehouseCkmc" name="warehouseCkmc" type="text"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">仓库位置</label>
					<div class="col-sm-4">
						<input class="form-control" id="warehouseCkwz" name="warehouseCkwz" type="text"/>
					</div>
					<label class="col-sm-2 control-label">仓库类型</label>
					<div class="col-sm-4">
						<select class="form-control" id="warehouseType" name="warehouseType">
            				<option value="成品仓库">成品仓库</option>
            				<option value="毛坯仓库">毛坯仓库</option>
            				<option value="装配仓库">装配仓库</option>
            				<option value="退货仓库">退货仓库</option>
            				<option value="销售仓库">销售仓库</option>
        				</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">负责人</label>
					<div class="col-sm-4">
						<input style="width:67%;display: inline-block;" class="form-control" id="warehouseFzr" name="warehouseFzr" type="text"/>
						<input style="display:none" id="warehousefzrId" name="warehousefzrId" type="text"/>
						<a class="btn btn-info"  onclick="newCheckperson('warehouseFzr','warehousefzrId')"><i class="fa fa-sign-out"></i>选择人员</a>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">备注</label>
					<div class="col-sm-10">
						<textarea class="form-control" id="warehouseBz" name="warehouseBz" type="text"></textarea>
					</div>
				</div>
			</fieldset>
		</form>
		<hr></hr>
	</div>
</div>
<div id="deptdialognew" style="display:none">
	<div class="zTreeDemoBackground" style="float:left">
		<ul id="treeDemo" class="ztree"></ul>
	</div>
</div>
<!-- 弹出框重写 -->
<div id="ycf-alert" class="modal">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> [Title]</h5>
          </div>
          <div class="modal-body small">
            <p>[Message]</p>
          </div>
          <div class="modal-footer" >
            <button type="button" class="btn btn-primary ok" data-dismiss="modal">[BtnOk]</button>
            <button type="button" class="btn btn-default cancel" data-dismiss="modal">[BtnCancel]</button>
          </div>
        </div>
      </div>
    </div>
<!-- 弹出框重写end -->
<%@include file="common/indexbottom.jsp"%>
<link rel="stylesheet" href="${pageContext.request.contextPath}/mystyle/zTreeStyle/css/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${pageContext.request.contextPath}/mystyle/zTreeStyle/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/mystyle/zTreeStyle/js/jquery.ztree.excheck.js"></script>
<script type="text/javascript">
function newCheckperson(name,id){
	$("#deptdialognew").dialog({
		autoOpen : false,   // 是否自动弹出窗口
		modal : true,    // 设置为模态对话框
		resizable : true,
		width : 510,   //弹出框宽度
		height : 440,   //弹出框高度
		title : "选择人员",  //弹出框标题
		position : "center",  //窗口显示的位置
		buttons:{
			'确定':function(){
				var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
				if(treeObj.getCheckedNodes().length!=0){
					var checkId = treeObj.getCheckedNodes()[0];
					$("#"+name+"").val(checkId.name);
					$("#"+id+"").val(checkId.id);
				}else{
					alert("请选择人员！");
				}
				$(this).dialog("close");
			},
			'取消':function(){
			$(this).dialog("close");
			}
		}
	});
	//console.log(obj.value);
	var json = "";
	var setting = {
			data: {
				simpleData: {
					enable: true
				}
			},
			check :{
				radioType : "all",
				enable: true,
				chkStyle: "radio"
			}
		};
	$.ajax({
        type: "get",
        url: "util/getusernew",
        dataType: "json",
        data: "",
        success: function(data) {
        	json = data;
			var zNodes = eval(json);
			//console.log(zNodes);
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
            alert(textStatus);
            alert(errorThrown);
        }
    });
    $("#deptdialognew").dialog("open");
}
$(function() {
window.Modal = function() {
    var reg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm');
    var alr = $("#ycf-alert");
    var ahtml = alr.html();
    
    var _alert = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-success').addClass('btn-primary');
        alr.find('.cancel').hide();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });
                }
            }
        };
    };

    var _confirm = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-primary').addClass('btn-success');
        alr.find('.cancel').show();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });

                }
            }
        };
    };

    var _dialog = function(options) {
        var ops = {
            msg: "提示内容",
            title: "操作提示",
            btnok: "确定",
            btncl: "取消"
        };

        $.extend(ops, options);

        console.log(alr);

        var html = alr.html().replace(reg,
        function(node, key) {
            return {
                Title: ops.title,
                Message: ops.msg,
                BtnOk: ops.btnok,
                BtnCancel: ops.btncl
            } [key];
        });

        alr.html(html);
        alr.modal({
            width: 500,
            backdrop: 'static'
        });
    }

    return {
        alert: _alert,
        confirm: _confirm
    }

} ();
});

function tijiao() {
Modal.confirm({
    msg: "是否新增？"
}).on(function(e) {
    var warehouseNumber = $("#warehouseNumber").val();
    var warehouseType = $("#warehouseType").val();
    var warehouseCkmc = $("#warehouseCkmc").val();
    var warehouseCkwz = $("#warehouseCkwz").val();
    var warehouseFzr = $("#warehouseFzr").val();
    var warehousefzrId = $("#warehousefzrId").val();
    var warehouseBz = $("#warehouseBz").val();
    $.ajax({
        type: "post",
        url: yongan.URL.warehouseAdd(),
        dataType: "json",
        data: {
            warehouseNumber: warehouseNumber,
            warehouseType: warehouseType,
            warehouseCkmc: warehouseCkmc,
            warehouseCkwz: warehouseCkwz,
            warehouseFzr: warehouseFzr,
            warehousefzrId: warehousefzrId,
            warehouseBz: warehouseBz
        },
        success: function(data) {

            if (data['success']) {
                Modal.alert({
                    msg: data['data']['stateinfo'],
                    title: '执行结果',
                    btnok: '确定',
                    btncl: '取消'
                }).on(function(e) {
                    window.close();
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
            alert(textStatus);
            alert(errorThrown);
        }
    });
});
}
</script>
  </body>
</html>